﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace CD2WebAudio3Lib
{
    public class main_settings : my_settings
    {
        private string m_SectionName = "frmMain";
        private string m_BoolTruePattern = ";yes;true;1;";

        public main_settings()
            : base(SettingsType.Machine, "Sibertec Services", "CD2WebAudio3")
        {
            // constructor code
        }

        public bool CreateMP3
        {
            get { return m_BoolTruePattern.Contains(Get_String_Setting(m_SectionName, "createMP3", "no").ToLower()); }
            set { Set_String_Setting(m_SectionName, "createMP3", value ? "yes" : "no"); }
        }

        public bool PublishFiles
        {
            get { return m_BoolTruePattern.Contains(Get_String_Setting(m_SectionName, "publishFiles", "no").ToLower()); }
            set { Set_String_Setting(m_SectionName, "publishFiles", value ? "yes" : "no"); }
        }

        public bool PublishSermon
        {
            get { return m_BoolTruePattern.Contains(Get_String_Setting(m_SectionName, "publishSermon", "no").ToLower()); }
            set { Set_String_Setting(m_SectionName, "publishSermon", value ? "yes" : "no"); }
        }

        public bool CloseWhenFinished
        {
            get { return m_BoolTruePattern.Contains(Get_String_Setting(m_SectionName, "closeWhenFinished", "no").ToLower()); }
            set { Set_String_Setting(m_SectionName, "closeWhenFinished", value ? "yes" : "no"); }
        }

        public bool ShutDownWhenFinished
        {
            get { return m_BoolTruePattern.Contains(Get_String_Setting(m_SectionName, "shutDownWhenFinished", "no").ToLower()); }
            set { Set_String_Setting(m_SectionName, "shutDownWhenFinished", value ? "yes" : "no"); }
        }

        public Point MainLocation
        {
            get
            {
                string p = Get_String_Setting(m_SectionName, "mainLocation", "0,0");
                string[] pp = p.Split(new char[] {','});

                if (pp.Length == 2)
                {
                    return new Point(int.Parse(pp[0].Trim()), int.Parse(pp[1].Trim()));
                }
                else
                {
                    return new Point(0,0);
                }
            }
            set
            {
                string p = value.X.ToString() + "," + value.Y.ToString();
                Set_String_Setting(m_SectionName, "mainLocation", p);
            }
        }

        public int MP3BitRate
        {
            get { return (int)Get_Numeric_Setting(m_SectionName, "mp3BitRate"); }
            set { Set_Numeric_Setting(m_SectionName, "mp3BitRate", value); }
        }

        public string OutputFolder
        {
            get { return Get_String_Setting(m_SectionName, "outputFolder", string.Empty); }
            set { Set_String_Setting(m_SectionName, "outputFolder", value); }
        }

        public string CopyrightText
        {
            get { return Get_String_Setting(m_SectionName, "copyrightText", string.Empty); }
            set { Set_String_Setting(m_SectionName, "copyrightText", value); }
        }

        public string PresetAuthors
        {
            get { return Get_String_Setting(m_SectionName, "presetAuthors", string.Empty); }
            set { Set_String_Setting(m_SectionName, "presetAuthors", value); }
        }

        public string PresetSuffixes
        {
            get { return Get_String_Setting(m_SectionName, "presetSuffixes", string.Empty); }
            set { Set_String_Setting(m_SectionName, "presetSuffixes", value); }
        }

        public bool PublishMP3
        {
            get { return m_BoolTruePattern.Contains(Get_String_Setting(m_SectionName, "publishMP3", "no").ToLower()); }
            set { Set_String_Setting(m_SectionName, "publishMP3", value ? "yes" : "no"); }
        }

        public string MP3Url
        {
            get { return Get_String_Setting(m_SectionName, "mp3Url", string.Empty); }
            set { Set_String_Setting(m_SectionName, "mp3Url", value); }
        }

        public string MP3Port
        {
            get { return Get_String_Setting(m_SectionName, "mp3Port", string.Empty); }
            set { Set_String_Setting(m_SectionName, "mp3Port", value); }
        }

        public string LastAuthor
        {
            get { return Get_String_Setting(m_SectionName, "lastAuthor", string.Empty); }
            set { Set_String_Setting(m_SectionName, "lastAuthor", value); }
        }

        public string LastSuffix
        {
            get { return Get_String_Setting(m_SectionName, "lastSuffix", string.Empty); }
            set { Set_String_Setting(m_SectionName, "lastSuffix", value); }
        }

        public string MP3Username
        {
            get { return Get_String_Setting(m_SectionName, "mp3Username", string.Empty); }
            set { Set_String_Setting(m_SectionName, "mp3Username", value); }
        }

        public string MP3Password
        {
            get { return Get_String_Setting(m_SectionName, "mp3Password", string.Empty); }
            set { Set_String_Setting(m_SectionName, "mp3Password", value); }
        }

        public bool UseAudioFile
        {
            get { return m_BoolTruePattern.Contains(Get_String_Setting(m_SectionName, "useAudioFile", "no").ToLower()); }
            set { Set_String_Setting(m_SectionName, "useAudioFile", value ? "yes" : "no"); }
        }
    }
}
